package com.ycx.ycxmybatismanagement.exception;

import com.ycx.ycxmybatismanagement.pojo.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
//声明全局异常处理器
@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(Exception.class)
    public Result exception(Exception e){
        log.error(e.getMessage(),e);
        return Result.error("网络异常请稍后重试!!!!!");
    }
    @ExceptionHandler(BizException.class)
    public Result bizException(BizException e){
        log.error(e.getMessage(),e);
        return Result.error(e.getMsg());
    }
    @ExceptionHandler(LoginException.class)
    public Result loginException(LoginException e){
        log.error(e.getMessage(),e);
        return Result.error(e.getMsg());
    }
}
